﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Robin.Domain.Entities;
using Robin.NHibernate.EntityMappings;

namespace Smart.Project.Data
{
    public class MProjectinfoMap : EntityMap<MProjectinfo, string>
    {
        public MProjectinfoMap() : base("PM_PROJECTINFO")
        {
            Id(x => x.Id);
            References(o => o.DEPT).NotFound.Ignore().LazyLoad().Column("DEPTID");
            Map(x => x.BMMC);
            Map(x => x.CATEGORY);
            Map(x => x.NAME);
            Map(x => x.ADDRESS);
            Map(x => x.BEGINTIME);
            Map(x => x.ENDTIME);
            Map(x => x.TYPECODE);
            Map(x => x.MONEY);
            Map(x => x.PARTYB);
            Map(x => x.STATUS);
            Map(x => x.PARTYAPERSON);
            Map(x => x.JFINFO);
            Map(x => x.PARTYBPERSON);
            Map(x => x.PARTYAPHONE);
            Map(x => x.BARCODE);
            Map(x => x.SIGNTIME);
            Map(x => x.CITYID);
            Map(x => x.ISVALID);
            Map(x => x.DESCRIBE);
            Map(x => x.UPDATEUSER);
            Map(x => x.UPDATETIME);
            Map(x => x.CREATEUSER);
            Map(x => x.CREATETIME);
            References(o => o.PARTYA).Not.LazyLoad().Column("PARTYA");
        }
    }
    /// <summary>
    /// 部门
    /// </summary>
    public class MProjectinfo : Entity<string>
    {
        #region 公共属性
        /// <summary>
        ///     关联部门
        /// </summary>
        public virtual MDepartment DEPT { get; set; }
        /// <summary>
        ///     部门
        /// </summary>
        public virtual string BMMC { get; set; }
        /// <summary>
        /// 类别（承包，分包）
        /// </summary>
        public virtual string CATEGORY
        { get; set; }


        /// <summary>
        /// 项目名称
        /// </summary>
        public virtual string NAME
        { get; set; }


        /// <summary>
        /// 项目地址
        /// </summary>
        public virtual string ADDRESS
        { get; set; }


        /// <summary>
        /// 项目开始时间
        /// </summary>
        public virtual Decimal BEGINTIME
        { get; set; }
        /// <summary>
        /// 项目开始时间格式转换
        /// </summary>
        public virtual string BEGINTIMETYPE
        {
            get
            {
                BEGINTIME = BEGINTIME == 0 ? decimal.Parse(DateTime.Now.ToString("yyyyMMdd")) : BEGINTIME;
                return DateTime.ParseExact(BEGINTIME.ToString(), "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture).ToString("yyyy-MM-dd");
            }
            set
            {
                BEGINTIME = Decimal.Parse(value.Replace("-",""));
            }
        }

        /// <summary>
        /// 项目结束时间
        /// </summary>
        public virtual Decimal ENDTIME
        { get; set; }

        /// <summary>
        /// 项目结束时间格式转换
        /// </summary>
        public virtual string ENDTIMETYPE
        {
            get
            {
                ENDTIME = ENDTIME == 0 ? decimal.Parse(DateTime.Now.ToString("yyyyMMdd")) : ENDTIME;
                return DateTime.ParseExact(ENDTIME.ToString(), "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture).ToString("yyyy-MM-dd");
            }
            set
            {
                ENDTIME = Decimal.Parse(value.Replace("-", ""));
            }

        }
        /// <summary>
        /// 项目类型编码（在建项目，虚拟项目）
        /// </summary>
        public virtual string TYPECODE
        { get; set; }


        /// <summary>
        /// 合同额
        /// </summary>
        public virtual Decimal MONEY
        { get; set; }


        /// <summary>
        /// 项目经理
        /// </summary>
        public virtual MUser PARTYA
        { get; set; }


        /// <summary>
        /// 项目经理联系电话
        /// </summary>
        public virtual string PARTYB
        { get; set; }


        /// <summary>
        /// 项目状态
        /// </summary>
        public virtual string STATUS
        { get; set; }


        /// <summary>
        /// 合同编号
        /// </summary>
        public virtual string PARTYAPERSON
        { get; set; }


        /// <summary>
        /// 合同签订时间
        /// </summary>
        public virtual Decimal UPDATETIME
        { get; set; }


        /// <summary>
        /// 项目甲方信息
        /// </summary>
        public virtual string JFINFO
        { get; set; }


        /// <summary>
        /// 甲方负责人名称
        /// </summary>
        public virtual string PARTYBPERSON
        { get; set; }


        /// <summary>
        /// 甲方负责人电话
        /// </summary>
        public virtual string PARTYAPHONE
        { get; set; }


        /// <summary>
        /// 条形码
        /// </summary>
        public virtual string BARCODE
        { get; set; }


        /// <summary>
        /// 签订时间
        /// </summary>
        public virtual Decimal SIGNTIME
        { get; set; }
        /// <summary>
        /// 项目结束时间格式转换
        /// </summary>
        public virtual string SIGNTIMETYPE
        {
            get
            {
                SIGNTIME = SIGNTIME == 0 ? decimal.Parse(DateTime.Now.ToString("yyyyMMdd")) : SIGNTIME;
                return DateTime.ParseExact(SIGNTIME.ToString(), "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture).ToString("yyyy-MM-dd");
            }
            set
            {
                SIGNTIME = Decimal.Parse(value.Replace("-", ""));
            }
        }

        /// <summary>
        /// 城市区划
        /// </summary>
        public virtual string CITYID
        { get; set; }


        /// <summary>
        /// 创建时间
        /// </summary>
        public virtual Decimal CREATETIME
        { get; set; }


        /// <summary>
        /// 是否有效 1 有效 0无效
        /// </summary>
        public virtual string ISVALID
        { get; set; }


        /// <summary>
        /// 创建人
        /// </summary>
        public virtual string CREATEUSER
        { get; set; }


        /// <summary>
        /// 修改人
        /// </summary>
        public virtual string UPDATEUSER
        { get; set; }


        /// <summary>
        /// 描述
        /// </summary>
        public virtual string DESCRIBE
        { get; set; }

        public virtual Decimal NUMBER
        { get; set; }
        #endregion
    }

}
